\section{Calculus Notation}

One of the first proving grounds for using \LaTeX{} for mathematical notation is calculus. If you can typeset calculus equations, you're well on your way to being able to typeset anything mathematical.

\begin{center}
  \fbox{\includegraphics[width=0.95\linewidth]{img-5-1}}
\end{center}

The first thing we'll need to be able to do is to typeset the major functions. Both polynomials and exponentials simply use the basic arithmetic symbols and superscripts for exponents. We've already seen these in an earlier video. To typeset the trigonometric functions and logarithms, you simply use a backslash before the function name. If you don't do this, your function name will be typeset as if it's a product of individual variables. Beginning users of \LaTeX{} don't notice the difference, but over time you'll start to see the slanted type for function names as being different and wrong. \LaTeX{} has most of the special functions you will ever need. If you're not sure if the one you need exists, just try typing backslash followed by your best guess and see what happens. You might be surprised! And if you ever needed to create a custom function, you can use \verb|\operatorname{}| to create those upright characters.

Let's look at the code for the evaluation of a limit.
\begin{center}
  \verb|\lim_{x \to \infty} \frac{x^2 + 1}{x^2 - 1} = 1|
\end{center}
At this point, you should have enough experience to put together the meaning of this code. The \verb|\lim| creates the limit notation, \verb|\to| makes the right arrow, and  \verb|\infty| makes the infinity symbol. The underscore is telling \LaTeX{} that you want the bracketed part to be typeset lower on the line. And then we have our fraction. Let's see how this looks as an inline equation and a display equation. 

\begin{center}
  \fbox{\includegraphics[width=0.6\linewidth]{img-5-2}}
\end{center}

Notice that the display style version actually typesets the variable of the limit beneath the lim. You can also see that the fraction is bigger and less cramped. Remember that you can force display style text inside of a paragraph by using \verb|\displaystyle|.

Summation notation is a good model for many other types of notation in \LaTeX. This is the notation for writing the harmonic series:
\begin{center}
  \verb|\sum_{n=1}^{\infty} \frac{1}{n}|
\end{center}
Again, notice how \LaTeX{} places the $n=1$ part either directly below the summation symbol or off to the side, depending on whether it's in display mode or inline mode.

\begin{center}
  \fbox{\includegraphics[width=0.8\linewidth]{img-5-3}}
\end{center}

There are times when you want your sums to have multiple lines of information, usually written on the lower part of the sum. For example, in differential equations your series solutions may only include the odd numbers. In order to do this, you can use \verb|\substack{}|. To create a second line, use a double backslash, just as when you create a new line in the align environment or in a tabular environment.

Notice that the inline style gets increasingly difficult to read as more notation gets crammed in. Also, as you play with this more you will notice that the stacking doesn't align the equal signs. In \LaTeX, there will always be a way to make things look exactly how you want them to look, but each time you push those details further, you will need to know more about the underlying structure of the program. There are several different solutions, and a \href{https://tex.stackexchange.com/questions/198771/align-in-substack}{link} to a discussion on \TeX{} Stack Exchange is provided in the description and in the transcript.

\begin{center}
  \fbox{\includegraphics[width=0.8\linewidth]{img-5-4}}
\end{center}

Here is one possible approach. The top portion is in the preamble and the bottom portion is the code to call it. As you can see, there is a lot of code here to do just that one alignment. One of the nice things about this is that you don't necessarily need to understand it all to use it. You can just copy and paste it, and see if it does what you need it to do. Of course, knowing more will give you the ability to modify the code to suit your needs, but I've personally found it rather rare to need to do that. The information on websites like \TeX{} Stack Exchange tends to be pretty good.

\begin{center}
  \fbox{\includegraphics[width=0.95\linewidth]{img-5-5}}
\end{center}

Integrals behave like sums. You put the limits above and below in exactly the same way. A single integral is \verb|\int|, a double integral is \verb|\iint|, and a triple integral is \verb|\iiint|. There is a distinction here between double or triple integrals and iterated integrals. The double and triple integral symbols are just single symbols with a single space to put information above or below. But if you have an iterated integral with limits on each part, you will need to write them as multiple single integrals.

You can have a little bit more control over where the limits go. The default position is slightly to the right of the integral sign, but if you use the \verb|\limits| command, you can shift those to be above and below the integral sign. As with many other things in \LaTeX, these are decisions that you can make for yourself.

And there's more to an integral than just the integral symbol. Within the integral notation is the differential term, and there are two minor details here that are worth mentioning. One notational quirk comes out of the spacing.

\begin{center}
  \fbox{\includegraphics[width=0.95\linewidth]{img-5-6}}
\end{center}

Some people find the first one to be a little cramped. It's not something that anyone should get too upset over, but there is some value to creating a small space between the integrand and the differential term. This space is created using \verb|\,|. The effect is a bit more pronounced when you have double or triple integrals. This special spacing symbol is one of several that are always available for use to create horizontal spaces. If you want to see a full list of spacing options, there's a \href{https://tex.stackexchange.com/questions/74353/what-commands-are-there-for-horizontal-spacing}{link} to a discussion post in the description and in the transcript.

\begin{center}
  \fbox{\includegraphics[width=0.95\linewidth]{img-5-7}}
\end{center}

The second notational quirk is that some people prefer the differential d to be in Roman font to distinguish it from a variable $d$. Here they are side-by-side. The upright d is created by explicitly calling \verb|\mathrm{}|. I personally don't have an issue with this, but you will find that some people can be very meticulous about those `d's. In the video on basic customizations, you will learn how to create a shortcut for this command to save yourself some typing. Those shortcuts are particularly helpful if you are working with Leibniz notation for derivatives because typing this repeatedly can become quite annoying after a while.

\begin{center}
  \fbox{\includegraphics[width=0.65\linewidth]{img-5-8}}
\end{center}

The last part of integral notation is the vertical bar we use for the evaluation of the integral. The simplest way to do this is to use \verb|\bigg\vert| for display style and \verb|\big\vert| for inline mode. The two \verb|\big(g)|s come from the same collection of modifiers that were used for parentheses earlier. 

\begin{center}
  \fbox{\includegraphics[width=0.95\linewidth]{img-5-9}}
\end{center}

Next, we'll look at some notation for derivatives. We've already pointed out the upright d that some people prefer for derivatives. The symbol for partial derivatives is \verb|\partial|. If you want to use the prime notation for derivatives, you will want want to use an apostrophe for each derivative, and the general $n$th derivative notation is drawn using superscript notation. Avoid using the double quote for the second derivative. \LaTeX{} will draw it differently and your notation will be inconsistent.

The dot notation for derivatives is created using these commands. You can only go up to four dots with this notation, but in practice you should probably never need that many anyway.

\begin{center}
  \fbox{\includegraphics[width=0.95\linewidth]{img-5-10}}
\end{center}

As we move on to multivariable calculus, we have to start working with vectors. The bracket notation for vectors is created using \verb|\langle| and \verb|\rangle|. You can also use the \verb|\left| and \verb|\right| commands to let \LaTeX{} decide how big to draw them, or you can manually size them like parentheses.

Some textbooks use a boldface notation for vectors. This can be accomplished using the \href{https://ctan.org/pkg/bm}{\texttt{bm}} package with the command \verb|\bm{}|. This is a very flexible package that can make all sorts of symbols boldface. But I personally don't like this. When writing things by hand, it's really hard to create an effective boldface font, and so I got into the habit of drawing vector arrows over my vectors. And I think it's useful for typed vectors to also do this for consistency.

There is a native vector symbol \verb|\vec{}| but it's not very good. So instead I use the \href{https://ctan.org/pkg/esvect}{\texttt{esvect}} package. The command used here is \verb|\vv{}|. The nice part about this is that it stretches the arrow to an appropriate length above the symbol. If you want the vector arrow to ignore the subscripts, you can use the \verb|\vv*{}{}| command. The first brackets are for the vector name and the second brackets are for the subscript.

\begin{center}
  \fbox{\includegraphics[width=0.85\linewidth]{img-5-11}}
\end{center}

This last slide is just a couple examples. The new symbols here are \verb|\nabla|, which is the upside down triangle used in multivariable calculus, and the closed contour integral symbol. Everything else is a combination of things we've seen before.

The next video will explain a few more of the odds and ends of mathematical notation.